namespace game {
    export let Instance: Game = null

    export class Game {
        private baseData: msg.T_UserBaseData
        private account: msg.T_AccountData
        public SendCmd(index: number, cmd: any) {
            MyApp.Instance.net.Send(index, cmd)
        }

        public OnConnect() {
            var cmd = new msg.MSG_LoginRequest_CS()
            cmd.request = "ltp001"
            this.SendCmd(Protocol.MSG_LoginRequest_CS_Index, cmd)
            console.log("连接成功 >>> ")
        }

        public LoginResponse(cmd: msg.MSG_LoginResponse_SC) {
            console.log("登录成功 >>> ")
            console.log(cmd)

            this.baseData = <msg.T_UserBaseData>cmd.userBase

            console.log("快速开始游戏 >>> ")
            var send = new msg.MSG_QuickStarGame_CS()
            this.SendCmd(Protocol.MSG_QuickStarGame_CS_Index, cmd)
        }

        public JoinGame() {
            let send = new msg.MSG_JoinGame_CS()
            this.SendCmd(Protocol.MSG_JoinGame_CS_Index, send)            
        }

        public OnGetGameData(cmd: msg.MSG_GameData_SC){

        }

        public UpdateUserTransfrom(cmd: msg.MSG_UpdateUserTransfrom_SC){

        }

        public MoveUser(x,y: number){
            let send = new msg.MSG_OperationUserMove_CS()
            send.ObjectID = 0
            send.MoveAngle.X = x
            send.MoveAngle.Y = y
            this.SendCmd(Protocol.MSG_OperationUserMove_CS_Index, send)            
            
        }
    }
}